//
//  SetTableViewCell.m
//  fp
//
//  Created by xingshuai on 2020/11/11.
//

#import "SetTableViewCell.h"

@interface SetTableViewCell ()

@property (nonatomic, strong) UILabel *leftTitle;
@property (nonatomic, strong) UISwitch *playSwitch;
@property (nonatomic, strong) UILabel *rightLabel;
@property (nonatomic, strong) UIImageView *rightImage;

@end

@implementation SetTableViewCell

+ (instancetype)cellWithTableView:(UITableView *)tableView {
    static NSString *ID = @"XAUsessSettingCell";
    
    id cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[self alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    self.leftTitle = [[UILabel alloc]init];
    [self.contentView addSubview:self.leftTitle];
    self.leftTitle.font = [UIFont pingFangSCWithWeight:FontWeightStyleRegular size:16];
    self.leftTitle.textColor = [UIColor colorWithHexString:@"#3B3B3B"];
    [self.leftTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.contentView).offset(15);
    }];
    
    self.playSwitch = [[UISwitch alloc]init];
    self.playSwitch.hidden = YES;
    [self.contentView addSubview:self.playSwitch];
    [self.playSwitch mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(self.contentView).offset(-20);
        make.size.mas_offset(CGSizeMake(54, 30));
    }];
    
    self.rightLabel = [UILabel new];
    self.rightLabel.hidden = YES;
    self.rightLabel.text = @"shuaidf";
    self.rightLabel.font = [UIFont pingFangSCWithWeight:FontWeightStyleRegular size:16];
    self.rightLabel.textColor = [UIColor colorWithHexString:@"#AFAFAF"];
    self.rightLabel.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:self.rightLabel];
    [self.rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(self.contentView).offset(-25);
    }];
    
    self.rightImage = [[UIImageView alloc] init];
    self.rightImage.hidden = YES;
    self.rightImage.image = [UIImage imageNamed:@"user_jt"];
    [self.contentView addSubview:self.rightImage];
    self.rightImage.contentMode = UIViewContentModeScaleAspectFill;
    [self.rightImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(self.contentView).offset(-20);
        make.size.mas_offset(CGSizeMake(12, 18));
    }];
    
}

-(void)setLeftStr:(NSString *)leftStr {
    self.leftTitle.text = leftStr;
}

-(void)setSizeStr:(NSString *)sizeStr {
    self.rightLabel.text = sizeStr;
}

-(void)setBanBenStr:(NSString *)banBenStr {
    self.rightLabel.text = banBenStr;
}

-(void)setIsHidenSwitch:(BOOL)isHidenSwitch {
    self.playSwitch.hidden = isHidenSwitch;
}

-(void)setIsHidenImg:(BOOL)isHidenImg {
    self.rightImage.hidden = isHidenImg;
}

-(void)setIsHidenLabel:(BOOL)isHidenLabel {
    self.rightLabel.hidden = isHidenLabel;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
